using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerOneWayPlatformState : PlayerClimbState
{
    public PlayerOneWayPlatformState(Player player, PlayerMoveData playerData, StateMachine stateMachine, string animName) : base(player, playerData, stateMachine, animName)
    {
    }

    Vector2 endPos;
    bool isOn;

    public override void Enter()
    {
        base.Enter();
        isOn = false;
        player.SetVelocityZero();
    }

    public override void LogicUpdate()
    {
        base.LogicUpdate();

        if (!isOn) 
        {
            player.transform.position = enterPos;
            player.SetVelocityZero();
            if (isAnimationFinish)
            {
                isOn = true;
                player.transform.position = endPos;
                stateMachine.ChangeState(player.IdleState);
            }
        }
        
    }

    public void SetEndPos(Vector3 endPos) { this.endPos = endPos; }

}
